package com.jiyi.adapter;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;

import com.jiyi.bean.datainput.DataInputSignRecordBean;
import com.jiyi.bean.datainput.DataInputSignRecordParent;
import com.swift.maintenance.R;

import java.util.ArrayList;


/**
 * @author zlw 
 */
public class DataInputSignRecordAdapter extends BaseExpandableListAdapter {
	private Context mContext;
	ArrayList<DataInputSignRecordParent> mList = new ArrayList<DataInputSignRecordParent>();
	LayoutInflater inflater;
	
	
	public DataInputSignRecordAdapter(Context context,ArrayList<DataInputSignRecordParent> liveList) {
		this.mContext = context;
		this.mList = liveList;
	}

	@Override
	public int getGroupCount() {
		return mList.size();
	}

	@Override
	public int getChildrenCount(int groupPosition) {
		int childSize = mList.get(groupPosition).getChildList().size();
		return childSize;
	}

	@Override
	public Object getGroup(int i) {
		return getGroup(i);
	}

	@Override
	public Object getChild(int i, int i1) {
		return getChild(i, i1);
	}

	@Override
	public long getGroupId(int i) {
		return i;
	}

	@Override
	public long getChildId(int i, int i1) {
		return i1;
	}


	@Override
	public boolean hasStableIds() {
		return false;
	}

	@Override
	public View getGroupView(final int position, boolean b, View view, ViewGroup viewGroup) {
		view = View.inflate(mContext, R.layout.item_huodong_head, null);
		GroupHolder holder = new GroupHolder(view);
		holder.mGroupTitleTv.setText(mList.get(position).getTitle());
		holder.mGroupTitleTv.setTextSize(18);
		return view;
	}
	@Override
	public View getChildView(int groupPosition, int childPosition, boolean b,
			View convertView, ViewGroup viewGroup) {
		DataInputSignRecordParent dataInputSignRecordParent = mList.get(groupPosition);
		DataInputSignRecordBean dataInputSignRecordBean = dataInputSignRecordParent.getChildList().get(childPosition);
		ChildHolderOne childHolderOne = null;
		if (convertView == null) {
			inflater = LayoutInflater.from(mContext);
			convertView = inflater.inflate(R.layout.item_data_input_sign_record, viewGroup,false);
			childHolderOne = new ChildHolderOne(convertView);
			convertView.setTag(childHolderOne);

		} else {
			childHolderOne = (ChildHolderOne) convertView.getTag();
		}
		
		childHolderOne.tvSignDate.setText(dataInputSignRecordBean.getDay());
		
		return convertView;
		
	}

	@Override
	public boolean isChildSelectable(int i, int i1) {
		return true;
	}

	class GroupHolder {
		TextView mGroupTitleTv;
		public GroupHolder(View view) {
			mGroupTitleTv = (TextView) view.findViewById(R.id.groupTitle);
		}
	}

	class ChildHolderOne {
		TextView tvSignDate;
		

		public ChildHolderOne(View convertView) {
			tvSignDate = (TextView) convertView.findViewById(R.id.tvSignDate);
		}
	}
}